package cn.lkk.samples.lang.thread.interrupt;


import java.util.Date;

/**
 * 测试线程的sleep和interrupt方法
 */
public class TestInterrupt {
    public static void main(String[] args) {
        Runner runner = new Runner();
        runner.start();

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {

        }
        runner.interrupt();
    }
}

class Runner extends Thread {
    @Override
    public void run() {
        while (true) {
            Date date = new Date();
            System.out.println(date);
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                return;
            }
        }

    }
}
